<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Flat extends Controller_Common
{
    public function action_search()
    {
        
           
$data = array('flatMin' => $_POST['flatMin'],
              'flatMax' => $_POST['flatMax'],
              'cMin' => $_POST['cMin'],
              'cMax' => $_POST['cMax'],
              'sel1' => $_POST['sel1'],
              'sel2' => $_POST['sel2'],
              'sel3' => $_POST['sel3']);
              
        
        
    $content = View::factory('result', $data);
     $this->template->content = $content; 
 $sidebar = View::factory('welcomesidebar');
        $this->template->sidebar = $sidebar;  
        
       if(isset($_POST["det"]))
        {
            $a=$_POST["idap"];
            Cookie::set('temp', $a);       
            $this->redirect('flat/details');
        } 
        
    }
    
    public function action_details()
    { 
        
        $apartments = ORM::factory('apartment')
                ->where( 'id', '=', Cookie::get('temp','no user'))
                ->find();
            if($apartments->loaded())
            {
                $data = array(
                    'id' => $apartments->id,
                    'region' => $apartments->city->region->name,
                    'city' => $apartments->city->name,
                    'street' => $apartments->street,
                    'house' => $apartments->house,
                    'floor' => $apartments->floor,
                    'number' => $apartments->number,
                    'numberRoom' => $apartments->numberRoom,
                    'area' => $apartments->area,
                    'price' => $apartments->price,
                    'description' => $apartments->description,     
                    'photo1' => $apartments->photo->photo1,
                    'photo2' => $apartments->photo->photo2,
                    'photo3' => $apartments->photo->photo3
                );          
            }
}
}

?>